<script lang="ts">
import { defineComponent } from "vue";

export default defineComponent({
  props: {
    info: { type: Object, required: true },
    isLarge: Boolean,
  },
});
</script>

<template>
  <view class="news-item">
    <image
      class="news-item-img"
      :style="{ height: isLarge ? '346rpx' : '' }"
      :src="info.pic_url"
      mode="aspectFill"
    />
    <template v-if="isLarge">
      <view class="news-item-mask"></view>
      <view class="news-item-title2">
        <text class="news-item-type">{{ info.cate_name }}</text
        >{{ info.title }}
      </view>
    </template>
    <view class="news-item-content" v-else>
      <view class="news-item-title">
        <text class="news-item-type">{{ info.cate_name }}</text
        >{{ info.title }}
      </view>
    </view>
  </view>
</template>

<style lang="scss">
.news-item {
  position: relative;

  .news-item-img {
    display: block;
    width: 100%;
    height: 252rpx;
    border-radius: 20rpx;
  }

  .news-item-wrapper {
    display: flex;
    padding: 20rpx;
  }

  .news-item-content {
    padding: 20rpx 10rpx;
  }

  .news-item-title {
    height: 80rpx;
    font-size: 28rpx;
    color: #242424;
    line-height: 40rpx;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    text-overflow: ellipsis;
    overflow: hidden;
  }

  .news-item-type {
    display: inline-block;
    padding: 0 6rpx;
    margin-right: 10rpx;
    font-size: 24rpx;
    color: #f36514;
    line-height: 28rpx;
    font-weight: 400;
    border-radius: 4rpx;
    border: 2rpx solid #f36514;
    background-color: #fcf1e9;
  }

  .news-item-mask {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 174rpx;
    border-radius: 0 020rpx 20rpx;
    background: linear-gradient(
      180deg,
      rgba(0, 0, 0, 0) 31%,
      rgba(2, 2, 2, 0.4)
    );
  }

  .news-item-title2 {
    position: absolute;
    left: 20rpx;
    right: 30rpx;
    bottom: 20rpx;
    font-size: 30rpx;
    color: #ffffff;
    line-height: 42rpx;
    font-weight: bold;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
  }
}
</style>